package com.xinhe.web.controller;

import com.xinhe.web.common.Result;
import com.xinhe.web.entity.RoleMenu;
import com.xinhe.web.service.RoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Set;

@Api(value = "系统角色菜单", tags = {"系统角色菜单"})
@RestController
@RequestMapping(value = {"/roleMenu"}, produces = {"application/json;charset=UTF-8"})
public class RoleMenuController {
    @Autowired
    private RoleMenuService roleMenuService;

    @ApiOperation(httpMethod = "POST", value = "保存系统角色菜单")
    @RequestMapping({"/saveRoleMenu"})
    public Result saveRoleMenu(Long roleId, Set<Long> menuIds) {
        return this.roleMenuService.saveRoleMenu(roleId,menuIds);
    }
    @ApiOperation(httpMethod = "GET", value = "删除系统角色菜单")
    @ApiImplicitParam(name = "roleMenuId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteRoleMenu"})
    public Result deleteRoleMenu(Long roleMenuId) {
        return this.roleMenuService.delete(roleMenuId);
    }
    @ApiOperation(httpMethod = "GET", value = "系统角色菜单详情")
    @ApiImplicitParam(name = "roleMenuId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailRoleMenu"})
    public Result detailRoleMenu(Long roleMenuId) {
        return this.roleMenuService.findById(roleMenuId);
    }

}